﻿using System;
using System.Collections.Generic;
using System.Text;
using Autofac;
namespace Website.Test
{
    public static class AutoFacRegister
    {
        private static IContainer _container;

        public static void RegisterContainer(IContainer container)
        {
            _container = container;
        }

        public static T GetService<T>()
        {
            if (_container == null)
            {
                throw new InvalidOperationException("The Autofac container has not been initialized.");
            }

            using (var scope = _container.BeginLifetimeScope())
            {
                return scope.Resolve<T>();
            }
        }


    }


}
